﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FundamentalsOfCompiling;

namespace CourseDesign_02
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        /**
         * 声明一些变量
         */
        public string fileSourcePath = null;

        /**
         * MenuItem
         */

        //  FileNew_Click
        private void FileNew_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.FileNew_Click(this);
        }

        //  FileOpen_Click
        private void FileOpen_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.FileOpen_Click(this);
        }

        //  FileSaveInput_Click
        private void FileSaveInput_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.FileSaveInput_Click(this);
        }

        //  FileSaveOutput_Click
        private void FileSaveOutput_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.FileSaveOutput_Click(this);
        }

        //  FileQuit_Click
        private void FileQuit_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.FileQuit_Click(this);
        }

        //  EditRevoke_Click
        private void EditRevoke_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditRevoke_Click(this);
        }

        //  EditRedo_Click
        private void EditRedo_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditRedo_Click(this);
        }

        //  EditNote_Click
        private void EditNote_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditNote_Click(this);
        }

        private void EditUnNote_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditUnNote_Click(this);
        }

        //  EditClearInput_Click
        private void EditClearInput_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditClearInput_Click(this);
        }

        //  EditClearOutput_Click
        private void EditClearOutput_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.EditClearOutput_Click(this);
        }

        //  HelpHelp_Click
        private void HelpHelp_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.HelpHelp_Click(this);
        }

        //  HelpAboutus_Click
        private void HelpAboutus_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.HelpAboutus_Click(this);
        }

        /**
         * RichTextBox
         */
        private void rtbInput_KeyUp(object sender, KeyEventArgs e)
        {
            ComponentEvent.rtbInput_KeyUp(this, e);
        }

        private void rtbOutput_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ComponentEvent.rtbOutput_MouseDoubleClick(this);
        }

        /// <summary>
        /// LexicalAnalysis_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LexicalAnalysis_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.LexicalAnalysis_Click(this);
        }

        /// <summary>
        /// SyntaxAnalysis_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SyntaxAnalysis_Click(object sender, RoutedEventArgs e)
        {
            ComponentEvent.SyntaxAnalysis_Click(this);
        }


        /* *************************************************************************
         * **   需要修改的
         * ********************************************************************** */
        // TODO: 更改所在类
        public void Write(String str)
        {
            this.rtbOutput.AppendText(str);
        }

        public void WriteLine(String str)
        {
            Write(str);
            this.rtbOutput.AppendText("\n");
        }
    }
}
